/**
* @description: 剑指 Offer 56 - I. 数组中数字出现的次数
* @author hewei
* @date 2022/7/22 20:58
* @version 1.0
*/

public class SingleNumbers {

    public int[] singleNumbers(int[] nums) {
        int temp = 0;
        for (int num : nums) {
            temp ^= num;
        }
        temp = Integer.lowestOneBit(temp);
        int a = 0;
        int b = 0;
        for (int num : nums) {
            if ((temp & num) == 0) {
                a ^= num;
            } else b ^= num;
        }
        return new int[]{a, b};
    }
}
